//
//  BROrderHeadView.m
//  Kexu
//
//  Created by IOS on 2023/7/17.
//

#import "BROrderHeadView.h"

@implementation BROrderHeadView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)didMoveToSuperview {
    [super didMoveToSuperview];
    if (self.superview) {
        [self mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.offset(0);
            make.width.mas_equalTo(kScreenWidth);
        }];
    }
    
}
- (void)willMoveToSuperview:(UIView *)newSuperview {
    [super willMoveToSuperview:newSuperview];
    
    [self layoutIfNeeded];
}

#pragma mark - UI --
- (void)setUI {
    
    [self addSubview:self.stateView];
    [self addSubview:self.stackView];
    [self.stateView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(20);
        make.left.offset(22);
        make.right.offset(0);
    }];
    [self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(34);
        make.right.offset(0);
        make.bottom.offset(-20);
        make.top.equalTo(self.stateView.mas_bottom).offset(8);
    }];
    
    UIView *line = [BRToolsView getLineView:UIColorMakeWithHex(@"#D2D8E2")];
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.offset(0);
        make.height.mas_equalTo(0.5);
    }];
}

- (BRStackLabelView *)stackView {
    
    if (_stackView == nil) {
        _stackView = [[BRStackLabelView alloc] init];
        _stackView.spacing = 8;
        [_stackView br_addSubLabel:@[@"--",@"--"]];
    }
    return _stackView;
}

- (BROrderStateView *)stateView {
    
    if (_stateView == nil) {
        _stateView = [[BROrderStateView alloc] init];
    }
    return _stateView;
}

@end
